<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@page import="com.yaodian100.mall.member.util.UserData"%>
<%@page import="com.yaodian100.ec.member.entity.Member"%>
<%@page import="com.yaodian100.ec.member.service.MemberService"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@page import="com.yaodian100.core.common.dao.impl.CommonCriteria"%>
<%@page import="org.apache.commons.lang.StringUtils"%>
<%@page import="com.yaodian100.core.common.utils.ServerValue"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<c-rt:set var="frontContextPath" value='<%=ServerValue.getFrontContextPath()%>'/>
<c-rt:set var="trustMembers" value='<%=ServerValue.getTrustMemberString() %>'/>
<c-rt:set var="isTrustMember" value="false"/>
<c:forEach var="as" items="${fn:split(trustMembers, ',')}">
<c:if test="${ member.applySource eq as }">
<c-rt:set var="isTrustMember" value="true"/>
</c:if>
</c:forEach>
<html>
<head>
<script language="javascript">
	$().ready(function(){

		$("#current_location").html('&nbsp;&gt;&nbsp;<a href="${frontContextPath}/member/modifydata.do">个人信息管理&nbsp;-&nbsp;修改个人信息</a>&nbsp;&gt;&nbsp;修改登录邮箱');
		$("#m_modifyData").css("font-weight","bold");
		
		if("${actionResult}" == "pwd_error"){
			$("#pwdTip").html("密码错误");
			$("#pwdTip").show();
		}

		if("${actionResult}" == "mail_exist"){
			$("#mailTip").html("此邮箱已被注册，请重新填写。");
			$("#mailTip").show();
		}
		
		$("#submit_data").click(function(){
			var isCorrect = true;
			//clear tips
			$("span:[id*=Tip]").hide();

			<c:if test="${!isTrustMember}">
			if($("#pwd").attr('value')==""){
				$("#pwdTip").html("请输入密码");
				$("#pwdTip").show();
				isCorrect = false;
			}
			</c:if>
			
			$("#mail").val(jQuery.trim($("#mail").val()).toLowerCase());
			var text = $("#mail").attr('value');
			if(text.length==0){
				$("#mailTip").html("请输入新邮箱地址");
				$("#mailTip").show();
				isCorrect = false;
			}else if(text == $("#omail").text()){
				$("#mailTip").html("新邮箱地址与旧邮箱地址相同");
				$("#mailTip").show();
				isCorrect = false;
			}else if(text.match(/.+@.+\..+/)==null || text.indexOf(' ')>=0 || chineseCount($("#mail").val())>0){
				$("#mailTip").html("邮箱地址格式不正确");
				$("#mailTip").show();
				isCorrect = false;
			}

			$("#rc_mail").val(jQuery.trim($("#rc_mail").val()).toLowerCase());
			if($("#rc_mail").val().length==0){
				$("#rc_mailTip").html("请再次输入您的邮箱地址");
				$("#rc_mailTip").show();
				isCorrect = false;
			}else if(text!=$("#rc_mail").val()){
				$("#rc_mailTip").html("两次输入的邮箱地址不一致");
				$("#rc_mailTip").show();
				isCorrect = false;
			}
			
			if(isCorrect){
				$("#modifyEmailForm").submit();
				return false;
			}
		});
	});
	
function chineseCount(word){
    var length=0;
    for(var cc=0;cc<word.length;cc++){
       var c = word.charCodeAt(cc);
      if (!(c>=32&&c<=126)) length++;
    }
    return length;
}
</script>
</head>
<body>
<h2>修改登录邮箱</h2>
    <!-- 內容 -->
      <div class="change-email">
          <p class="c-f LH-1of5">&nbsp;</p>
          <s:form action="goModifyEmail.do" method="post" id="modifyEmailForm">
         <p class="">在您修改登录邮箱时，耀点100会向新设定的登录邮箱发送一封验证邮件，请依据验证邮件进行确认。<br />如有疑问，请访问<a href="/help/">帮助中心</a>获得更多帮助。
         </p>
          <div class="d-show">
            <ul>
              <li class="w-1of1"><strong style="padding-left:2em;">目前登录邮箱地址：</strong><span id="omail"><c:if test="${!(member.email eq 'xx' || empty member.email)}">${member.email}</c:if></span></li>
              <c:if test="${! empty member.tempEmail}">
              <li class="w-1of1"><div><strong style="padding-left:1em;">等待确认的邮箱地址：</strong></div><div class="txt-rd"><p>${member.tempEmail}</p><p>这是您前次申请修改后尚未完成确认的登录邮箱地址，<br />如还未收到确认邮件或填写错误，请您在下方重新填写新的邮箱地址。</p></div></li>
              </c:if>
              <li class="w-1of1"><div><strong style="padding-left:3.1em;">新登录邮箱地址：</strong></div><div><input type="text" name="mail" id="mail" value="${mail}" maxlength="100" /><span class="txt-gy">请使用常用及安全的电子邮箱作为您的登录邮箱。</span><span style="display:block;"><span id="mailTip" class="msg rn" style="display:none;">邮箱格式错误</span></span></div></li>
              <li class="w-1of1"><div><strong>请再次输入新邮箱地址：</strong></div><div><input type="text" id="rc_mail" maxlength="100" /><span style="display:block;"><span id="rc_mailTip" class="msg rn" style="display:none;">两次输入的邮箱地址不一致</span></span></div></li>
              <c:if test="${!isTrustMember}">
              <li class="w-1of1"><div><strong style="padding-left:6.5em;">登录密码：</strong></div><div><input type="password" name="pwd" id="pwd" maxlength="16"/><span style="display:block;"><span id="pwdTip" class="msg rn" style="display:none;">请输入密码</span></span></div></li>
              </c:if>
            </ul>
          </div>
          <input type="hidden" name="loginID" value="${member.loginId}" />
          <p align="center"><a href="javascript:;" id="submit_data" class="btn-mid">确认修改</a></p>
          </s:form>
      </div>
    <!-- 內容 -->
</body>
</html>